import java.util.List;
import java.util.ArrayList;
public class ArrayListDemo02 {
    public static void main(String[] args) {
        //创建新闻标题对象
        NewsTitle news1 = new NewsTitle(1,"狼堡","灰太狼");
        NewsTitle news2 = new NewsTitle(2,"青青草原","喜羊羊");
        //创建存储新闻对象的集合对象
        List newsTitleList = new ArrayList();
        //按照次序依次添加新闻标题
        newsTitleList.add(news1);
        newsTitleList.add(news2);
//        System.out.println(newsTitleList);
        System.out.println("总共有" + newsTitleList.size() + "则新闻。");
        //遍历
        for (Object obj : newsTitleList) {
            NewsTitle name = (NewsTitle) obj;
            NewsTitle reporter = (NewsTitle)obj;
            System.out.println("关于" + name.getTitleName() + "新闻的记者是" + reporter.getReporter());
        }
    }
}
